#ifndef ASTAR_H
#define ASTAR_H
#include <queue>
#include <list>
#include "config.h"
#include "global.h"

using namespace std;

struct TreeNode{
    Point p;
    TreeNode *parent;

    int d; // 距离起点的步数
    int cost; // 距离起点的步数+距离终点的曼哈顿距离
    TreeNode():parent(nullptr){}
    TreeNode(const Point& p, int d):p(p), parent(nullptr), d(d){}
};

struct TreeNodeCompare {
    bool operator()(const TreeNode* a, const TreeNode* b) {
        return a->cost > b->cost;
    }
};


bool isValidPoint(char map[MAP_SIZE][MAP_SIZE], bool visited[MAP_SIZE][MAP_SIZE], const Point& p);
list<Point> FindRoute(Point src, Point dst, char map[MAP_SIZE][MAP_SIZE]);

#endif